//
//  SHHttpManager.h
//  ShinyOrder
//
//  Created by 王方伟 on 16/7/25.
//  Copyright © 2016年 ShinyHub. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"

@interface SHHttpUtil : NSObject

+ (instancetype)sharedHttpUtil;
+(void)cancelManager;

/**
 *  发送post请求
 *
 *  @param url    请求url
 *  @param params 请求参数
 */
+(NSURLSessionDataTask *)postWithURL:(NSString *)url params:(NSDictionary *)params success:(void(^)(id responseObject))success failure:(void(^)(NSError *failure))failure;

/**
 *  发送put请求
 *
 *  @param url    请求url
 *  @param params 请求参数
 */
+(NSURLSessionDataTask *)putWithURL:(NSString *)url params:(NSDictionary *)params success:(void(^)(id responseObject))success failure:(void(^)(NSError *failure))failure;
/**
 *  发送get请求
 *
 *  @param url    请求url
 *  @param params 请求参数
 */
+(NSURLSessionDataTask *)getWithURL:(NSString *)url params:(NSDictionary *)params success:(void(^)(id responseObject))success failure:(void(^)(NSError *failure))failure;

/**
 *  发送delete请求
 *
 *  @param url    请求url
 *  @param params 请求参数
 */
+(NSURLSessionDataTask *)deleteWithURL:(NSString *)url params:(NSDictionary *)params success:(void(^)(id responseObject))success failure:(void(^)(NSError *failure))failure;


/**
 *  发送一个POST请求(上传文件数据)
 *
 *  @param url     请求路径
 *  @param params  请求参数
 *  @param formDataArray  文件参数
 *  @param success 请求成功后的回调
 *  @param failure 请求失败后的回调
 */
+(NSURLSessionDataTask *)postWithURL:(NSString *)url params:(NSDictionary *)params formDataArray:(NSArray *)formDataArray success:(void (^)(id))success failure:(void (^)(NSError *))failure;
@end


/**
 *  用来封装文件数据的模型
 */
@interface FormData : NSObject
/**
 *  文件数据
 */
@property (nonatomic, strong) NSData *data;

/**
 *  参数名
 */
@property (nonatomic, copy) NSString *name;

/**
 *  文件名
 */
@property (nonatomic, copy) NSString *filename;

/**
 *  文件类型
 */
@property (nonatomic, copy) NSString *mimeType;

@end
